//
//  FounctionBaseCell.swift
//  Wmsmobile
//
//  Created by Nick xu on 16/8/9.
//  Copyright © 2016年 hddden. All rights reserved.
//

import UIKit

protocol HDInputViewStateProtocol:NSObjectProtocol { //需要扫码输入的cell需遵守此协议
    var state: inputViewState? {get set}
}

protocol HDgetAndSetProtocol: NSObjectProtocol { //能够取值和赋值的cell需要遵守该协议
    func getText() -> (String?)
    func SetText(_ text: String?)
}

class HDFounctionBaseCell: UITableViewCell {
    //MARK: - property
    lazy var iconView:UIImageView = {
        let icon = UIImageView()
        return icon
    }()
    lazy var titleView:UILabel = {
        let titleView = UILabel()
        titleView.textColor = UIColor.hexStringToUIColor("#333333")
        titleView.font = UIFont.systemFont(ofSize: self.getFont())
        titleView.adjustsFontSizeToFitWidth = true
//        titleView.backgroundColor = UIColor.red
        return titleView
    }()
    lazy var separatorView:UIView = {
        let view = UIView(frame: CGRect(x: 13, y: self.height - 0.5, width: KscreenWidth - 26, height: 0))
        view.backgroundColor = UIColor.hexStringToUIColor("#cccccc")
        return view
    }()

    var info:[String : String]?{
        didSet{
            self.titleView.text = info![FounctionCellsModel.title] ?? ""
        }
    }
    
//    var constraintLeft: ConstraintDescriptionEditable?
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    
    //MARK: - life cycle
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: UITableViewCellStyle.default, reuseIdentifier: "BarcodeInputCell")
        self.setUpUIBase()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
        self.setUpUIBase()
    }
    
    required init(){
        super.init(style: UITableViewCellStyle.default, reuseIdentifier: "BarcodeInputCell")
        self.setUpUIBase()
    }

    //MARK: - private
    func setUpUIBase(){
        //添加自定义imageView
        //添加自定义textView
        self.selectionStyle = .none
        self.contentView.addSubview(iconView)
        self.contentView.addSubview(titleView)
        self.contentView.addSubview(separatorView)
        self.separatorView.isHidden = false
        self.iconView.isHidden = true
        self.iconView.snp.makeConstraints { (make) in
//            make.centerY.equalTo(self.contentView)
            make.top.equalTo(12)
            make.leading.equalTo(self).offset(9)
        }
        self.titleView.snp.makeConstraints { (make) in
            make.leading.equalTo(self.contentView).offset(15)
            make.bottom.equalTo(-12)
            make.width.equalTo(80)
        }
    }
    func getFont() -> CGFloat {
        return (WMSFonts["founctionCell"]!)[userInfo!.fontLevel.rawValue]
    }
    
    //MARK: - public
     func clearContent(){
        
    }

}
